package com.vince.test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.vince.util.DBUtil;

public class InsertDataToOrder {
	private static String SQL="insert into torder(order_code,buyer,sum,delivery_method,"
			+ "last_modify_date,created_date) values(?,'admin1',?,?,now(),now())";
	public static void main(String[] args) {
		InsertDataToOrder obj=new InsertDataToOrder();
		obj.insertData("圆珠笔",4.5,"快递");
	
	
	}
	
	public  void insertData(String name,Double sum,String method ){
		DBUtil mysql=new DBUtil();
		Connection conn = null;
		PreparedStatement ps = null;
		try {
			conn=mysql.getConnection();
			ps=conn.prepareStatement(SQL);
			ps.setString(1, name);
			ps.setDouble(2, sum);
			ps.setString(3, method);
			ps.execute();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
		
			mysql.releaseResource(conn, ps, null);
		}
		
	}

}
